package com.one.mycommons.init;

import java.io.File;
import java.util.Date;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.one.mycommons.DateForm;
import com.one.mycommons.properties.ProperReader;

public class MyContextListener implements ServletContextListener {
	
//	public static final Logger CONSOLE_LOGGER = Logger.getLogger("console");
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
//		CONSOLE_LOGGER.info("系统停止..  : " + DateForm.date2StringByMin(new Date()));
		
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
//		ApplicationContext ctx = new ClassPathXmlApplicationContext("/WEB-INF/config/spring-applicationContext.xml");
//		CONSOLE_LOGGER.info("系统初始化..  : " + DateForm.date2StringByMin(new Date()));
		//路径
		String contextPath = arg0.getServletContext().getRealPath(File.separator) + "/WEB-INF/config/config.properties";
		//读取 properties文件
		ProperReader.readProperties(contextPath);
		
	}

}
